<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>

<?php //echo $phpJS; ?>

<form action="<?php echo site_url('buyer/shows/submit_bid');?>" name="submit_bid" id="submit_bid" method="post" enctype="multipart/form-data" >
<input type="hidden" name="ref_no" id="ref_no" value="<?php echo $_GET['ref_no'];?>" />
<input type="hidden" name="scrid" id="scrid" value="<?php echo $_GET['scrid'];?>" />

<div id="center-wrap" class="ui-corner-tl ui-corner-tr">
	<div id="navigation" class="ui-corner-all"><ul><?php echo $navigator;?></ul></div>
	<div class="clrboth"></div>
	
	<div class="row" id="booking_zone">
		<div class="column grid_9 items" id="id_1">
			<div class="column grid_2">Booking for:</div>
			<div class="column grid_6" id="zone_slb">
				<?php 
					echo form_dropdown( 'booking_for[]',
										$options = countryZoneDataConfig(),
										$selected = array(),
										"id='booking_for[]' class='width270' onchange='changeZone(\"id_1\",this.value);' "
									);	
				?>
			</div>
			<div class="clrboth"></div>
			
			<div class="column grid_2">Country:</div>
			<div class="column grid_6" id="country_slb">
				<?php 
					$country_records = $items['country'];
					$options = array();
					foreach($country_records as $record){
						$options[$record->id] = $record->name;
					}
					echo form_dropdown( 'country[]',
										$options,
										$selected = array(),
										"id='country[]' class='width270' onchange='changeCountry(\"id_1\",this.value);' "
									);	
				?>
			</div>
			<div class="clrboth"></div>
			
			<div class="column grid_2">City:</div>
			<div class="column grid_6" id="city_slb">
				<?php 
					$city_records = $items['city'];
					$options = array();
					foreach($city_records as $record){
						$options[$record->id] = $record->name;
					}
					echo form_dropdown( 'city[]',
										$options,
										$selected = array(),
										"id='city[]' class='width270'"
									);	
				?>
			</div>
			
			<div class="clrboth"></div>
			
			<div class="column grid_2">
				Venue:
			</div>
			<div class="column grid_6">
				<input type="text" maxlength="200" name="venue[]" id="venue_1" value="" class="inputText" class="required" />
			</div>
			
			<div class="clrboth"></div>
		
			<div class="column grid_2">
				Address:
			</div>
			<div class="column grid_6">
				<input type="text" maxlength="200" name="address[]" id="address_1" value="" class="inputText" class="required" />
			</div>
				
			<div class="clrboth"></div>
			
			<div class="column grid_2">
				Capacity:
			</div>
			<div class="column grid_6">
				<input type="text" maxlength="200" name="capacity[]" id="capacity_1" value="" class="inputText" class="required" />
			</div>
				
			<div class="clrboth"></div>
			
			<div class="column grid_2">
				Ticket Pricing:
			</div>
			<div class="column grid_6">
				<input type="text" maxlength="200" name="ticket_pricing[]" id="ticket_pricing_1" value="" class="inputText" class="required" />
			</div>
				
			<div class="clrboth"></div>
			
			<div class="column grid_2">
				Potential Sponsors:
			</div>
			<div class="column grid_6">
				<input type="text" maxlength="200" name="potential_sponsors[]" id="potential_sponsors_1" value="" class="inputText" class="required" />
			</div>
				
			<div class="clrboth"></div>
			
		</div>
		<div class="clrboth"></div>
	</div>
	
	<div class="clrboth"></div>
	
	<div class="row">	
		<div class="column grid_9">
			<div class="column grid_6">
				<input type="button" value="Add a city" class="add_a_city" id="add_a_city" name="add_a_city" onclick="addACity();" />
				&nbsp;	&nbsp;&nbsp;
				<?php echo loader_image(" class='hidden' id='loader_add_a_city' ");?>
			</div>
			<div class="clrboth"></div>
		</div>
		<div class="clrboth"></div>
	
		<div class="column grid_9">	
			<div class="clrboth"></div>	
			
			<div class="column grid_2">
				Offer Price:
			</div>
			<div class="column grid_6">
				<input type="text" maxlength="20" name="offer_price" id="offer_price" value="" class="inputText" class="required" />&nbsp;&nbsp; USD
			</div>
				
			<div class="clrboth"></div>
			
			<div class="column grid_2">
				Promoter History:
			</div>
			<div class="column grid_6">
				<table cellspacing="3">
					<tr>
						<td width="60px">Artist/Production</td>
						<td width="30px">Year</td>
						<td width="50px">Capacity</td>
						<td width="30px">Venue</td>
					</tr>
			
					<tr>
						<td><input type="text" name="artist_production1" id="artist_production1" value="" maxlength="200" style="width:120px;" class="in-tbl"/></td>
						<td><input type="text" name="year1" id="year1" value="" maxlength="6" style="width:70px;" class="in-tbl"/></td>
						<td><input type="text" name="capacity1" id="capacity1" value="" maxlength="200" style="width:100px;" class="in-tbl"/></td>
						<td><input type="text" name="venue1" id="venue1" value="" maxlength="200" style="width:70px;" class="in-tbl"/></td>
					</tr>
					
					<tr>
						<td><input type="text" name="artist_production2" id="artist_production2" value="" maxlength="200" style="width:120px;" class="in-tbl"/></td>
						<td><input type="text" name="year2" id="year2" value="" maxlength="6" style="width:70px;" class="in-tbl"/></td>
						<td><input type="text" name="capacity2" id="capacity2" value="" maxlength="200" style="width:100px;" class="in-tbl"/></td>
						<td><input type="text" name="venue2" id="venue2" value="" maxlength="200" style="width:70px;" class="in-tbl"/></td>
					</tr>
					
					<tr>
						<td><input type="text" name="artist_production3" id="artist_production3" value="" maxlength="200" style="width:120px;" class="in-tbl"/></td>
						<td><input type="text" name="year3" id="year3" value="" maxlength="6" style="width:70px;" class="in-tbl"/></td>
						<td><input type="text" name="capacity3" id="capacity3" value="" maxlength="200" style="width:100px;" class="in-tbl"/></td>
						<td><input type="text" name="venue3" id="venue3" value="" maxlength="200" style="width:70px;" class="in-tbl"/></td>
					</tr>
					
					<tr>
						<td><input type="text" name="artist_production4" id="artist_production4" value="" maxlength="200" style="width:120px;" class="in-tbl"/></td>
						<td><input type="text" name="year4" id="year4" value="" maxlength="6" style="width:70px;" class="in-tbl"/></td>
						<td><input type="text" name="capacity4" id="capacity4" value="" maxlength="200" style="width:100px;" class="in-tbl"/></td>
						<td><input type="text" name="venue4" id="venue4" value="" maxlength="200" style="width:70px;" class="in-tbl"/></td>
					</tr>
					
				</table>
			</div>
				
			<div class="clrboth"></div>
	<!--	 	
			<div class="column grid_2">
				Term and Conditions:
			</div>
			<div class="column grid_4">
				<input type="checkbox" name="agree_term_n_conditional" id="agree_term_n_conditional" checked="checked" onclick="agree_term(this.checked);" /> 
				&nbsp;&nbsp; 
				<a href="javascript:void(0);" onclick="openTermAndConditional();" >I agree of this term and conditions.</a>
			</div>
	-->	 	
			<div class="clrboth"></div>
		
			
		</div>
		<div class="clrboth"></div>
		
		<div class="column grid_9" id="after_agreement" style="margin-top:30px;">	
			<div class="clrboth"></div>	
			<div class="column grid_2">
				&nbsp;
			</div>
			<div class="column grid_2">
				<input type="submit" id="submit_bid" name="submit_bid" value="Submit Bid" class="ui-corner-all button-yellow" />
				&nbsp;	&nbsp;&nbsp;
				<?php echo loader_image(" class='hidden' id='submit_bid_loader' ");?>
				<div class="clrboth"></div>	
				<span id="submit_bid_error" class="red hidden">Please fill require fields input.</span>
			</div>
			
			<div class="column grid_2">
				<input type="button" id="ask_seller_question" onclick="openDialogAskQuestion();" name="ask_seller_question" value="Ask Seller a Question" class="ui-corner-all button-yellow" />
				<div class="clrboth"></div>	
				<span id="ask_seller_question_stt" class="green hidden">Sent message.</span>
			</div>
		</div>
		<div class="clrboth"></div>
		
	</div>

	
<div id="term_and_conditional" title="Term and conditions" class="hidden" style="padding:10px 30px;">
	{pyro:getpost:body id="22"}	
</div>

<div id="ask_question" title="Ask Seller a Question" class="hidden" style="padding:10px 30px;">
	<div class="column grid_2">Subject:</div>
	<div class="column grid_4"><input type="text" name="subject" id="subject" value="" maxlength="200" style="width:350px;" /></div>
	
	<div class="clrboth"></div>
	
	<div class="column grid_2">Message:</div>
	<div class="column grid_4"><textarea name="message" id="message" style="width:350px;height:200px;"></textarea></div>
	
	<div class="clrboth"></div>
	
	<div class="column grid_2" style="margin-top:20px;">
		<input type="button" id="submit_question" name="submit_question" onclick="submitQuestion();" value="Submit Question" class="ui-corner-all button-yellow" />
	
	</div>
</div>

</div>
<div class="clrboth"></div>
</form>	


<script type="text/javascript">
	$(document).ready(function() {
	/*	if($('#agree_term_n_conditional').attr('checked')){
			$('#after_agreement').show();
		}else{
			$('#after_agreement').hide();
		}	
		*/
	});
	
	function agree_term(checked){
		if(checked){
			$('#after_agreement').show();
			
		}else{
			$('#after_agreement').hide();
			
		}
	}
	
	function openTermAndConditional(){
		$('#term_and_conditional').dialog(
			{
				 width: 1000,
				 resizable: false,
				 height:550,
			}
		);
	}
	
	function openDialogAskQuestion(){
		$('#ask_question').dialog(
			{
				 width: 500,
				 resizable: false,
				 height:400,
			}
		);
	}
	
	function submitQuestion(){
		$.post(BASE_URI+"buyer/shows/submitQuestionSeller",{subject:$('#subject').val(),message:$('#message').val(),ref_no:$('#ref_no').val()},function(response){
			if(response == 'ok'){
				$('#ask_question').dialog( 'close');
				$('#ask_seller_question_stt').show();
			}
		});
	}
	
	function changeZone(positionId, value){
		$.post(BASE_URI+"buyer/shows/ajax_changeZone",{value:value,positionId:positionId},function(response){
			$('#'+positionId+" #country_slb").html(response);
			var firstValue = $('#'+positionId+" #country_slb select").val();
			changeCountry(positionId, firstValue);
		});
	}
	
	function changeCountry(positionId, value){
		$.post(BASE_URI+"buyer/shows/ajax_changeCountry",{value:value,positionId:positionId},function(response){
			$('#'+positionId+" #city_slb").html(response);
		});
	}
	
	function addACity(){
		$('#loader_add_a_city').removeClass("hidden");
		var currentItem = $('#booking_zone .items').size();
		
		$.post(BASE_URI+"buyer/shows/ajax_addBookingfor",{currentItem:currentItem},function(response){
			$("#booking_zone").append(response);
			$('#loader_add_a_city').addClass("hidden");
		});
	}
	
	function remove_booking_item(id){
		$("#booking_zone #"+id).remove();
	}
	google.setOnLoadCallback(function() {
		$('.removeitem').live('click',function(){
			$id= $(this).attr('rel');
			$("#booking_zone #"+ $id).remove();
		});
	});
</script>
